#ifndef USK_EVENT_ADMIN_IMPL_H
#define USK_EVENT_ADMIN_IMPL_H

#include <memory>
#include "Poco/BasicEvent.h"
#include "cppmicroservices/ServiceReference.h"
#include "cppmicroservices/em/EventAdmin.hpp"
#include "cppmicroservices/em/EventHandler.hpp"
#include "usk_ldap_filter.hpp"


using namespace cppmicroservices::service::em;

namespace usk::core {

    class USKEventAdminImplPrivate;
    class OSGI;
    class USKEventAdminImpl : public EventAdmin {
    public:
        explicit USKEventAdminImpl(OSGI *osgi);
        ~USKEventAdminImpl() override;

        void PostEvent(Event const &evt) noexcept override;

        void SendEvent(Event const &evt) noexcept override;

    protected:
        std::vector<cppmicroservices::ServiceReference<EventHandler>>
        GetMatchedEventHandlersReference(Event const &evt);

    private:
        /// @brief osgi框架对象
        OSGI *osgi_ = nullptr;

        /// @brief 事件对象
        Poco::BasicEvent<Event> event_;

        /// @brief 事件主题过滤LDAPFilter
        std::shared_ptr<USKCachedTopicFilter> topic_ldap_filter_;
    };

    struct EventTaskers {
        std::vector<cppmicroservices::ServiceReference<EventHandler>> event_handlers;
    };


} // namespace usk::core


#endif
